package only.my.railgunys.shooting;

import only.my.railgunys.artifact.ArtifactSuitEffect;
import only.my.railgunys.artifact.imp.BlizzardStrayer;
import only.my.railgunys.artifact.imp.Emblem;
import only.my.railgunys.artifact.imp.Gladiator;
import only.my.railgunys.bean.Character;
import only.my.railgunys.bean.Enemy;
import only.my.railgunys.bean.Weapon;
import only.my.railgunys.repository.SceneRepository;
import only.my.railgunys.utils.ArtifactSetUtils;
import only.my.railgunys.utils.Crutch;
import only.my.railgunys.utils.FightUtils;
import only.my.railgunys.weapon.MistsplitterReforged;
import only.my.railgunys.weapon.PrimordialJadeCutter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

import static only.my.railgunys.preparation.SingleData.getSceneList;

@Component
public class Ayaka {
    @Autowired
    SceneRepository sceneRepository;

    public static Character getNormal90() {
        Character ayaka90 = initAyaka90();
        Enemy enemy = FightUtils.initNormal90(2);
        ayaka90.setEnemy(enemy);
        ayaka90.setSkillDmg(2.02);
        Crutch.doubleIceTeam(ayaka90);
        return ayaka90;
    }
    public void initAyakaData(){
        Weapon primordialJadeCutter = new PrimordialJadeCutter(1);
        calc(primordialJadeCutter);

        Weapon mr = new MistsplitterReforged(1);
        calc(mr);
    }

    private void calc(Weapon weapon) {
        BlizzardStrayer blizzardStrayer = new BlizzardStrayer();
        ArtifactSuitEffect emblem = new Emblem();

        Character ayakaB4 = getNormal90();
        List<Character> pjcB4List = FightUtils.calcSuitIncrease(ayakaB4, weapon, blizzardStrayer::setEffect2Piece, blizzardStrayer::setEffect4Piece);
        sceneRepository.saveAll(getSceneList(pjcB4List));

        Character ayakaC4 = getNormal90();
        List<Character> mrB4List = FightUtils.calcSuitIncrease(ayakaC4, weapon, emblem::setEffect2Piece, emblem::setEffect4Piece);
        sceneRepository.saveAll(getSceneList(mrB4List));
    }

    public static List<Character> pjB4Dmg(Character ayaka90,  int refineLevel){
        Weapon primordialJadeCutter =  new PrimordialJadeCutter(refineLevel);
        primordialJadeCutter.mainStatEnhance(ayaka90);

        List<Character> temp = ArtifactSetUtils.mainStatRollEnhance(ayaka90);
        List<Character> characters = ArtifactSetUtils.possibleStatRollEnhance(temp,25);

        ArtifactSuitEffect blizzardStrayer4 = new BlizzardStrayer();
        characters.stream()
                .map(blizzardStrayer4::setEffect2Piece)
                .map(blizzardStrayer4::setEffect4Piece)
                .map(primordialJadeCutter::subStatEnhance)
                .map(primordialJadeCutter::specialAbility)
                .forEach(FightUtils::calcTotalDmg);
        return characters;
    }
    public static List<Character> pjB4bl2Gla2Dmg(Character ayaka90,  int refineLevel){
        Weapon primordialJadeCutter =  new PrimordialJadeCutter(refineLevel);
        primordialJadeCutter.mainStatEnhance(ayaka90);

        List<Character> temp = ArtifactSetUtils.mainStatRollEnhance(ayaka90);
        List<Character> characters = ArtifactSetUtils.possibleStatRollEnhance(temp,25);

        ArtifactSuitEffect blizzardStrayer4 = new BlizzardStrayer();
        ArtifactSuitEffect gladiator = new Gladiator();
        characters.stream()
                .map(blizzardStrayer4::setEffect2Piece)
                .map(gladiator::setEffect2Piece)
                .map(primordialJadeCutter::subStatEnhance)
                .map(primordialJadeCutter::specialAbility)
                .forEach(FightUtils::calcTotalDmg);
        return characters;
    }
    public static List<Character> mrB4Dmg(Character ayaka90,  int refineLevel){
        Weapon mistsplitterReforged =  new MistsplitterReforged(refineLevel);
        mistsplitterReforged.mainStatEnhance(ayaka90);

        List<Character> temp = ArtifactSetUtils.mainStatRollEnhance(ayaka90);
        List<Character> characters = ArtifactSetUtils.possibleStatRollEnhance(temp,25);

        ArtifactSuitEffect blizzardStrayer4 = new BlizzardStrayer();
        characters.stream()
                .map(blizzardStrayer4::setEffect2Piece)
                .map(blizzardStrayer4::setEffect4Piece)
                .map(mistsplitterReforged::subStatEnhance)
                .map(mistsplitterReforged::specialAbility)
                .forEach(FightUtils::calcTotalDmg);
        return characters;
    }
    public static List<Character> mrB2G2mg(Character ayaka90, Weapon weapon){
        ArtifactSuitEffect emblem = new Emblem();
        return FightUtils.calcSuitIncrease(ayaka90, weapon, emblem::setEffect2Piece, emblem::setEffect4Piece);
    }

    public  static Character initAyaka90(){
        Character ayaka = new Character();
        ayaka.setHp(12858D);
        ayaka.setRole(1);
        ayaka.setLevel(90);
        ayaka.setAtk(342D);
        ayaka.setCritDmg(88.4);
        ayaka.setCritRate(5D);
        ayaka.setDescription("90级神里");
        ayaka.setIncrease(18D);
        ayaka.setRecharge(100.0);
        ayaka.setAtkUseful(true);
        ayaka.setHpUseful(true);
        ayaka.setRechargeUseful(true);
        ayaka.setCritRateUseful(true);
        ayaka.setElementDmgUseful(true);
        return ayaka;
    }
}
